<template>
  <div class="novel-item-wrap flex" @click="toNovelDetail(novelItem.bookname)">
    <div class="novel-img">
      <img alt="" v-lazy="novelItem.book_cover">
    </div>
    <div class="novel-info">
      <p class="info-item novel-title">{{novelItem.bookname}}</p>
      <p class="info-item novel-desc text-overflow">{{novelItem.book_info}}</p>
      <div class="info-item novel-author">
        <div class="left-info">
          <van-icon name="contact"/>
          <span>{{novelItem.author_name}}</span>
        </div>
        <div class="novel-cate">
          <span class="tag-item serials">{{novelItem.stat_name}}</span>
          <span class="tag-item" v-show="novelItem.tag" v-for="(tag,i) in novelItem.tag" :key="i">{{tag}}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
  import {Component, Vue, Prop, Emit} from "vue-property-decorator";
  import {Icon} from "vant";
  import {Lazyload} from "vant";

  Vue.use(Lazyload, {});
  @Component({
    components: {
      [Icon.name]: Icon,
      [Lazyload.name]: Lazyload,
    }
  })
  export default class NovelItem extends Vue {
    @Prop({default: {}})
    private novelItem!: object;

    toNovelDetail(name:string) {
      this.$router.push({
        name: "novelDetail",
        query: {name}
      });
    }
  }
</script>
<style lang="scss">
  .novel-item-wrap {
    width: 100%;
    padding: 10px 16px;
    border-bottom: 1px solid #f4f4f4;
    .novel-img {
      margin-right: 10px;
      img {
        width: 70px;
        height: 90px;
      }
    }
    .novel-info {
      color: #969ba3;
      .info-item {
        &:last-child {
          margin-bottom: 0;
        }
      }
      .novel-title {
        font-size: 16px;
        font-weight: bold;
        color: #333;
        margin-bottom: 6px;
      }
      .novel-desc {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        white-space: normal;
        -webkit-line-clamp: 2;
        font-size: 14px;
        margin-bottom: 2px;
      }
      .novel-author {
        width: 100%;
        height: 50px;
        font-size: 13px;
        position: relative;
        .novel-cate {
          max-width: 150px;
          overflow-x: auto;
          font-size: 11px;
          color: #969ba3;
          position: absolute;
          right: 0;
          top: 5px;
          white-space: nowrap;
          .tag-item {
            padding: 0 2px;
            border: 1px solid #969ba3;
            border-radius: 3px;
            margin-right: 3px;
            &:last-child {
              margin-right: 0;
            }
          }
          .serials {
            border-color: #ed424b;
            color: #ed424b;
          }
        }
      }
    }
  }
</style>


